﻿using System;

namespace Xwltz.Net.Tools.Browser
{
    public class Opera : BaseBrowser
    {
        public Opera(string agent)
        {
            var agent1 = agent.ToLower();
            var opera12 = BrowserType.Opera.ToString().ToLower();

            if (agent1.Contains(opera12))
            {
                var first = agent1.IndexOf("version", StringComparison.Ordinal);
                var version = agent1.Substring(first + "version".Length + 1);
                Version = ToVersion(version);
                Type = BrowserType.Opera;
            }

            var opera15 = "opr";
            if (agent1.Contains(opera15))
            {
                var first = agent1.IndexOf(opera15, StringComparison.Ordinal);
                var version = agent1.Substring(first + opera15.Length + 1);
                Version = ToVersion(version);
                Type = BrowserType.Opera;
            }
        }
    }
}
